package com.thebitstream.sandy.support;

import java.util.ArrayList;

import org.red5.io.utils.ObjectMap;

/**
 * @author Andy Shaules
 *
 */
public class ClientData {

	private String id = "";

	private double x = 0;

	private double y = 0;

	private double z = 0;

	private double rX = 0;

	private double rY = 0;

	private double rZ = 0;

	private double vX = 0;

	private double vY = 0;

	private double vZ = 0;

	private double vrX = 0;

	private double vrY = 0;

	private double vrZ = 0;

	private double aX = 0;

	private double aY = 0;

	private double aZ = 0;

	private double arX = 0;

	private double arY = 0;

	private double arZ = 0;
	
	private long when=System.currentTimeMillis();

	private double[] lastPosition = new double[18];

	public ObjectMap<Object, Object> data = new ObjectMap<Object, Object>();

	public double[] getPosition() {
		return new double[] { x, y, z, rX, rY, rZ, vX, vY, vZ, vrX, vrY, vrZ, aX, aY, aZ, arX, arY, arZ,when };
	}

	public double[] getLastPosition() {
		return lastPosition;
	}

	public void setId(String iD) {
		id = iD;
	}

	public String getId() {
		return id;
	}

	public ClientData() {
	}

	public void readReturn(ArrayList<Object> object2) {
		lastPosition = getPosition();
		
		x = Double.valueOf(object2.get(1).toString());
		y = Double.valueOf(object2.get(2).toString());
		z = Double.valueOf(object2.get(3).toString());
		rX = Double.valueOf(object2.get(4).toString());
		rY = Double.valueOf(object2.get(5).toString());
		rZ = Double.valueOf(object2.get(6).toString());
		vX = Double.valueOf(object2.get(7).toString());
		vY = Double.valueOf(object2.get(8).toString());
		vZ = Double.valueOf(object2.get(9).toString());
		vrX = Double.valueOf(object2.get(10).toString());
		vrY = Double.valueOf(object2.get(11).toString());
		vrZ = Double.valueOf(object2.get(12).toString());
		aX = Double.valueOf(object2.get(13).toString());
		aY = Double.valueOf(object2.get(14).toString());
		aZ = Double.valueOf(object2.get(15).toString());
		arX = Double.valueOf(object2.get(16).toString());
		arY = Double.valueOf(object2.get(17).toString());
		arZ = Double.valueOf(object2.get(18).toString());
		when=Long.valueOf(object2.get(19).toString());
	}

	public void setPosition(double[] position) {
		lastPosition = getPosition();

		x = (position[0]);
		y = (position[1]);
		z = (position[2]);
		rX = position[3];
		rY = position[4];
		rZ = position[5];
		vX = position[6];
		vY = position[7];
		vZ = position[8];
		vrX = position[9];
		vrY = position[10];
		vrZ = position[11];
		aX = position[12];
		aY = position[13];
		aZ = position[14];
		arX = position[15];
		arY = position[16];
		arZ = position[17];
		when=(long) position[18];
	}

	public String[] toObject() {
		return new String[] { id, String.valueOf(x), String.valueOf(y), String.valueOf(z),
				String.valueOf(rX), String.valueOf(rY), String.valueOf(rZ), String.valueOf(vX), String.valueOf(vY),
				String.valueOf(vZ), String.valueOf(vrX), String.valueOf(vrY), String.valueOf(vrZ), String.valueOf(aX),
				String.valueOf(aY), String.valueOf(aZ), String.valueOf(arX), String.valueOf(arY), String.valueOf(arZ),String.valueOf(when)

		};
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getX() {
		return x;
	}

	public void setY(double y) {
		this.y = y;
	}

	public double getY() {
		return y;
	}

	public void setZ(double z) {
		this.z = z;
	}

	public double getZ() {
		return z;
	}

}
